package character.reader;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
//FileReader文件字符流，解决中文乱码问题，用于读取纯文本文件
public class FileReaderDemo1 {
    public static void main(String[] args) throws IOException {
//        method1();
        FileReader fr=new FileReader("G:\\Javatest2\\character\\reader\\a.txt");
        int i;

        char[] chs=new char[1024];

        while((i=fr.read(chs))!=-1){
            String s=new String(chs,0, i);
            System.out.println(s);
        }
        fr.close();

    }

    private static void method1() throws IOException {
        FileReader fr=new FileReader("G:\\Javatest2\\character\\reader\\a.txt");
        int i;
        while((i=fr.read())!=-1){
            System.out.print((char)i);
        }
    }
}
